#!/usr/bin/env python
#coding=utf-8
#Just for test
#A simple python program
#Writen by RAh-XePhON
#@http://ToKyo-JuPiTer.Blogspot.com/
import sys

class main:
    """#the main class"""
    def __init__(self):
        """#do something when class Initialize"""
        print 'class Initialize'
    def bin(self):
        """#calculate 1G + 1M + 1K -1 and change into bin"""
        print 'start!'
        ans = [0]
        a = 1024*1024*1024 + 1024*1024 + 1024 - 1
        print a
        x = 1
        i = 0
        answer = ""
        while x:
            r = a / 2
            q = a - r*2
            print r, "......", q
            if a < 2:
                x = 0
                ans[i] = q
                i+=1
                ans += [0]
                ans[i] = r
                i+=1
            else:
                a = r
                ans[i] = q
                ans += [0]
                i+=1
        while i:
            i-=1
            answer += "%d" % ans[i]
        print answer
    def max(self, x = 0, y = 1):
        print x, y
        if x > y:
            return y
        elif y >x:
            return x
        else:
            return 0
    def math2(self):
        time = 0
        sum = 0
        a = [ 2, 3, 8, 10 ]
        b = [ 0, 0, 0, 0 ]
        for i in range(4):
            for j in range(4):
                if j != i:
                    b[i] = b[j] = 1
                    print '1- ',
                    print b
                    for ii in range(4):
                        if b[ii]:
                            b[ii] = 0
                            print '2- ',
                            print b
                            for iii in range(4):
                                for jjj in range(4):
                                    if iii != jjj:
                                        if (not b[iii]) and (not b[jjj]):
                                            b[iii] = b[jjj] = 1
                                            print '3- '
                                            print b
                                            for iiii in range(4):
                                                if b[iiii]:
                                                    b[iiii] = 0
                                                    print '4- '
                                                    print b
                                                    for i5 in range(4):
                                                        for j5 in range(4):
                                                            if i5 != j5:
                                                                if (not b[i5]) and (not b[j5]):
                                                                    b[i5] = b[j5] = 1
                                                                    print '5- '
                                                                    print b
                                                                    if b[0] and b[1] and b[2] and b[3]:
                                                                        print "Start\n========================"
                                                                        print "First, No. %s and %s cross the bridge" % (i, j),
                                                                        print "then, No. %s backed" % ii,
                                                                        print "then, No. %s and %s cross the bridge" % (iii, jjj),
                                                                        print "then, No. %s backed" % iiii,
                                                                        print "Final, No. %s and %s cross the bridge.\nAll people crossed the bridge." % (i5, j5)
                                                                        sum += 1
        print "The total way to cross bridge: ",
        print sum
        #print time
    def math1(self):
        cow = [7]
        i = 0
        last_year = 20
        year = 1
        while year <= last_year:
            if year < 4:
                year += 1
            else:
                for i in range( len(cow) ):
                    if cow[i] < 4:
                        cow[i] += 1
                    else:
                        cow[i] = 7
                        cow += [0]
                year += 1
        print "\nThe number of cow is :",
        print len( cow )
        return "Finish"
    def main(self):
        """#the main function of main class"""
        print 'testing'        #Just do something for testing
        #inn=raw_input('input any word or "Error": ')
        inn = 'E'
        print inn
        print '––'.decode('utf-8')
        a = '––'.decode('utf-8')
        #try:
            #a.encode('utf-8')
        print a.encode('utf-8')
        print 'END'
        sys.stdout.flush()
        print "Please choose a one of the functions below: "
        print "a) change to bin"
        print "b) calculate cow"
        print "c) calculate the shortest time"
        choose = raw_input( ": ")
        if choose == "a":
            self.bin()
        elif choose == "b":
            self.math1()
        elif choose == "c":
            self.math2()
        else:
            print "the choose is not correct"
    def countx(self):
        x=0
        sum=0
        ps=1
        while ps:
            print x
            sum=sum+x
            x+=1
            if x >= 100: ps=0
            sys.stdout.flush()

if __name__ == "__main__":
    #Program Start
    error=0        #Set the default is no error
    main=main()
    main.main()
    #main.bin()
    sys.exit(0)        #Exit the program without error
